<%@ page language="java"  pageEncoding="UTF-8" %>
<%@ page import="com.shopping.modean.*" %>
<%@ page import="com.shopping.service.*" %>
<%@ page import="java.util.*" %>
<%@  include file="_session_check.jsp" %>

<%
  request.setCharacterEncoding("UTF-8");
  int id = Integer.valueOf(request.getParameter("id"));
  Category c = null;
  CategoryService categoryService = new CategoryService();
  
  String action = request.getParameter("action");
  //处理form表单提交
  if(action != null && action.trim().equals("categoryUpdate")) {
	  String name = request.getParameter("name");
	  String descr = request.getParameter("descr");
	  
	  Category updateRecord = new Category(id,name,descr);
	  categoryService.update(updateRecord);
	  response.sendRedirect("category_list.jsp");
	  return;
	  
  //处理页面跳转
  } else {
	  c = categoryService.detail(Integer.valueOf(id));
  } 

%>

<!DOCTYPE html>
<html>
<head>
  <title>修改分类</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>

<body>

  <form method="post" name="category_add" action="category_update.jsp">
    <input type="hidden" name="action" value="categoryUpdate" />
    <input type="hidden" name="id" value="<%=id %>" />
	<table class="tableborder" align="center" cellpadding="4" cellspacing="1" width="97%">
        <tr>
           <td>&nbsp;</td>
        </tr>
        <tr>
           <td>&nbsp;</td>
        </tr>
        <tr>
          <td class="altbg1" width="21%"><span style="color:red">*</span>分类名称:</td>
          <td class="altbg2">
            <input id="name" name="name" size="25" maxlength="25" type="text" value="<%=c.getName() %>"> 
            <span id="usermsg"></span>
          </td>
        </tr>
		
        <tr>
          <td class="altbg1" valign="top">分类描述:</td>
          <td class="altbg2"><textarea name="descr" cols="60" rows="5" id="descr"><%=c.getDescr() %></textarea></td>
        </tr>
        <tr>
          <td class="altbg1"></td>
          <td class="altbg2"><input name="regsubmit" value="提 &nbsp; 交" type="submit"></td>
        </tr>
      </tbody>
    </table>
    
  </form>
  
</body>
</html>